package com.system.Controller;
import com.common.Entity.Result;
import com.system.Entity.OssContent;
import com.system.Service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/image")
public class ImageController {
    @Autowired
    private ImageService imageService;
    @PostMapping("/imageshow")
    public Result upload_show(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.upload_show(file);
        return Result.success(url);
    }

    @DeleteMapping("/deleteImageshow")
    public Result deleteImage_show(@RequestParam String url) {
        imageService.deleteImage_show(url);
        return  Result.success();
    }

    @PostMapping("/imageprogram")
    public Result upload_program(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.upload_program(file);
        return Result.success(url);
    }

    @DeleteMapping("/deleteImageprogram")
    public Result deleteImage_program(@RequestParam String url) {
        imageService.deleteImage_program(url);
        return  Result.success();
    }



    @PostMapping("/imageschoolfounder")
    public Result upload_schoolfounder(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.upload_schoolfounder(file);
        return Result.success(url);
    }

    @DeleteMapping("/deleteImageschoolfounder")
    public Result deleteImage_schoolfounder(@RequestParam String url) {
        imageService.deleteImage_schoolfounder(url);
        return  Result.success();
    }



    //艺术家图片上传
    @PostMapping("/imageArtist")
    public Result upload_artist(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.upload_artist(file);
        return Result.success(url);
    }
    @DeleteMapping("/deleteImageArtist")
    public Result deleteImage_artist(@RequestParam String url) {
        imageService.deleteImage_artist(url);
        return  Result.success();
    }


    //艺术家作品图片上传
    @PostMapping("/imageArtistWork")
    public Result upload_artistWork(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.upload_artistWork(file);
        return Result.success(url);
    }
    @DeleteMapping("/deleteImageArtistWork")
    public Result deleteImage_artistWork(@RequestParam String url) {
        imageService.deleteImage_artistWork(url);
        return  Result.success();
    }

    //艺术家历史图片上传
    @PostMapping("/imageArtistHistory")
    public Result upload_artistHistory(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.upload_artistHistory(file);
        return Result.success(url);
    }
    @DeleteMapping("/deleteImageArtistHistory")
    public Result deleteImage_artistHistory(@RequestParam String url) {
        imageService.deleteImage_artistHistory(url);
        return  Result.success();
    }

    //曲目封面图
    @PostMapping("/DramaImage")
    public Result upload_dramaImage(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.upload_dramaImage(file);
        return Result.success(url);
    }

    //曲目音频
    @PostMapping("/DramaAudio")
    public Result upload_dramaAudio(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.upload_dramaAudio(file);
        return Result.success(url);
    }
    //曲目视频
    @PostMapping("/DramaVideo")
    public Result upload_dramaVideo(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.upload_dramaVideo(file);
        return Result.success(url);
    }


    //文章图片
    @PostMapping("/articleImage")
    public Result articleImage(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.articleImage(file);
        return Result.success(url);
    }

    //文章视频
    @PostMapping("/articleVideo")
    public Result articleVideo(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.articleVideo(file);
        return Result.success(url);
    }

    @PostMapping("/post")
    public Result post(@RequestParam("file") MultipartFile file) throws IOException {
        String url = imageService.post(file);
        return Result.success(url);
    }
    @DeleteMapping("/deletePost")
    public Result deletePost(@RequestParam String url) {
        imageService.deletePost(url);
        return  Result.success();
    }

    @GetMapping("/credentials")
    public Result getCredentials() {
        OssContent ossContent = imageService.getCredentials();
        return Result.success(ossContent);
    }






}
